package top.dark.design.patterns.singleton;

/**
 * Author: Darkn
 * description: 懒汉式，同步代码块，double-check。即保证了懒加载，高效率，but会有个小bug，当需要构造实例化多个成员变量，容易产生空指针异常
 * Create Time: 2021/4/25 16:28
 */
public class Singleton05 {
    private static Singleton05 singleton = null;
    public static Singleton05 getInstance(){
        if (singleton == null) {
            synchronized (Singleton05.class) {
                if (singleton == null) {
                    singleton = new Singleton05();
                }
            }
        }
        return singleton;
    }
}
